package app

import (
	"v3workshop/pkg/uix"
)

type ListOption struct {
}

func (m *Manager) List(opt *ListOption) error {
	err := m.LoadConfig()
	if err != nil {
		return err
	}
	err = m.LoadParcels()
	if err != nil {
		return err
	}
	items := make([][]string, 0, len(m.Parcels)+1)
	items = append(items, []string{"ID", "Name", "size","Version", "GameVersion", "Description"})
	for _, p := range m.Parcels {
		item := []string{p.Id}
		item = append(item, p.Metadata.Name,p.GetSize() ,p.Metadata.Version, p.Metadata.SupportedGameVersion, p.Metadata.ShortDescription)
		items = append(items, item)
	}
	uix.Table(items)
	return nil
}
